const fs=require("fs");
const path=require("path");
let path01=path.join(__dirname,'\\1.txt');
let path02=path.join(__dirname,'\\2.txt');
let path03=path.join(__dirname,'\\3.txt');

fs.readFile(path01,'utf-8',(error,data1)=>{
  if(error){
    console.log(error);
  }
  //第一次读取文件成功
  fs.readFile(path02,'utf-8',(error,data2)=>{
    if(error){
      console.log(error);
    }
    //第二次读取文件成功
    fs.readFile(path03,'utf-8',(error,data3)=>{
      if(error){
        console.log(error);
      }
      //第三次读取文件成功
      console.log(data1+data2+data3);
      data=data1+data2+data3;
      fs.writeFile(path.join(__dirname,'\\data.txt'),data,error=>{
        if(error){
          console.log(error);
        }
        console.log("写入成功！");
      });
    })
  })
});